package com.ershijin.my;

import com.ershijin.util.MD5Util;
import org.springframework.security.crypto.password.PasswordEncoder;

import java.util.Locale;

public class MyMd5PasswordEncoder implements PasswordEncoder {

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        return encodedPassword.toLowerCase(Locale.ROOT).equals(MD5Util.encode((String)rawPassword).toLowerCase(Locale.ROOT));
    }

    @Override
    public String encode(CharSequence rawPassword) {
        return MD5Util.encode((String)rawPassword);
    }
}